package week02;

public class T017 {
	
	public static long num(int n){
        int[]aaa={0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6};//1~20
        long[]b=new long[n+1];
        for(int i=1;i<n+1;i++){//n不大于1000的前提下
            if(i>=1&&i<=20) b[i]=aaa[i];//1~20
            else if(i==40) b[i]=5;//40
            else if(i<100) b[i]=aaa[i%10]+b[i-i%10];//30.50.60.70.80.90 2:teen与ty
            else if(i==100) b[i]=10;//100 one hundred
            else if(i%100==0&&i<1000) b[i]=aaa[i/100]+b[100]-3;//200,300,400,500,600,700,800,900
            else if(i<1000) b[i]=b[i-i%100]+b[i%100]+3;//141:one hundred and forty-one
            else if(i==1000) b[i]=11;//one thousand
        }
        long m=0;
        System.out.println(b[80]);//测试
        System.out.println(b[89]);
        for(int i=0;i<=n;i++) m+=b[i];
        return m;
    }
    public static void main(String[] args) {
        long m=num(1000);
        System.out.println(m);
    }


}
